<?php
namespace common\components;

class Ystring
{
	/**
	 * 字符串转驼峰
	 * @param  string  $str 字符串
	 * @param  string  $separator 分隔符
	 * @param  boolean $ucfirst 首字母转大写
	 * @return string
	 */
	public static function camelCase($str, $separator = '-', $ucfirst = false) {
		$str = preg_replace_callback('/([' . $separator . ']+([a-z]{1}))/i' , function ( $matches ){
		    return  strtoupper ( $matches [2]);
		}, $str);
		return  $ucfirst  ? ucfirst( $str ) :  $str ;
	} 
}